package org.stvd;

import java.io.UnsupportedEncodingException;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@EnableSwagger2
@Configuration
public class AppConfiguration extends WebMvcConfigurationSupport{
    
    public AppConfiguration()  {
        System.out.println("系统初始化......");
    }

    public void init(){
        
    }
    
    @Bean
    public Docket api() throws UnsupportedEncodingException {
        return new Docket(DocumentationType.SWAGGER_2)
            .select()
            .apis(RequestHandlerSelectors.basePackage("org.stvd.controller.admin"))
            .paths(PathSelectors.any())
            .build()
            .groupName(new String("OpenDAO".getBytes(),"UTF-8"))
            .pathMapping("/")
            .apiInfo(apiInfo())
            .host("https://project.opendao.cn");
    }
    
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
            .title("OpenDAO系统接口文档")
            .description("文档中可以查询及测试接口调用参数和结果")
            .version("1.0")
            .build();
    }
    
    public static void main(String[] args){
        
    }
    
}
